package com.gooluke.datasource;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author gooluke
 */
@Setter
@Getter
@Component
@ConfigurationProperties(prefix = "spring")
public class MultiDataSourceProperties {

    /**
     * 这里的datasource是因为配置是spring.datasource.xx.xx,要配置成datasource,这样才会把配置自动映射进来
     * 分别映射到url、driverClassName、username、password
     */
    private Map<String, DataSourceConfig> datasource;

    @Setter
    @Getter
    public static class DataSourceConfig {
        private String url;
        private String driverClassName;
        private String username;
        private String password;
    }
}
